# This sample code supports Appium Python client >=2.3.0
# pip install Appium-Python-Client
# Then you can paste this into a file and simply run with Python
import time
from telnetlib import EC

from selenium.webdriver.support import expected_conditions as EC
from appium.options.common.base import AppiumOptions
from appium.webdriver.common.appiumby import AppiumBy
from selenium.webdriver.support.wait import WebDriverWait


from Login2 import Login2
from Login3 import Login3
from Login4 import Login4
# For W3C actions
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.actions import interaction
from selenium.webdriver.common.actions.action_builder import ActionBuilder
from selenium.webdriver.common.actions.pointer_input import PointerInput
class Judge:
    def judge(self,driver):

        wait = WebDriverWait(driver, 10)

        # 优先检测 el1（Login4）
        try:
            el1 = wait.until(
                EC.presence_of_element_located((AppiumBy.ID, "com.ss.android.ugc.aweme:id/cxq"))
            )
            print("找到 Login4 元素")
            login4 = Login4()
            login4.login4(driver)
            return
        except:
            print("未找到 Login4 元素，继续检测 Login2")

        # 次优检测 el2（Login2）
        try:
            el2 = wait.until(
                EC.presence_of_element_located((AppiumBy.ID, "com.ss.android.ugc.aweme:id/title"))
            )
            print("找到 Login2 元素")
            login2 = Login2()
            login2.login2(driver)
            return
        except:
            print("未找到 Login2 元素，执行 Login3")

        # 默认执行 Login3
        login3 = Login3()
        login3.login3(driver)